﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using YiSha.Business.YiDongYuan;
using YiSha.Entity.YiDongYuan;
using YiSha.Model.Param;
using YiSha.Model.Param.OrganizationManage;
using YiSha.Model.Param.YiDongYuan;
using YiSha.Util;
using YiSha.Util.Extension;
using YiSha.Util.Model;

namespace YiSha.Admin.WebApi.Controllers
{
    /// <summary>
    /// 尾气检测接口
    /// </summary>
    [Route("[controller]/[action]")]
    [ApiController]
    [AuthorizeFilter]
    public class TestResultController : ControllerBase
    {
        private DetectionResultBLL resultBLL = new DetectionResultBLL();

        /// <summary>
        /// 保存尾气检测数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TData<string>> Save([FromForm] DetectionResultEntity entity)
        {
            //if (Request.Form.Keys.Count > 0)
            //{
            //    string log = "";
            //    foreach (var item in Request.Form.Keys)
            //    {
            //        log += $"{item}:{Request.Form[item]};";
            //    }
            //    LogHelper.Info(log);
            //}
            //if (entity.VIN.IsNullOrEmpty() && !Request.Form["VIN"].IsNullOrEmpty())
            //    entity.VIN = Request.Form["VIN"];
            //if (entity.carbrand.IsNullOrEmpty() && !Request.Form["carbrand"].IsNullOrEmpty())
            //    entity.carbrand = Request.Form["carbrand"];
            TData<string> obj = await resultBLL.SaveForm(entity);
            return obj;
        }
    }
}